<?php
	
	// Session
	session_start();
	
	
	// Nese leximi i faqes behet nga ndonje burim ekstern duke mos e definuar identifikatorin e librit
	if (!isset($_GET['id'])) {
		header("Location: index.php?splash=wrong");
		exit;
	}
	
	
	// Integrimi i skedave sistemore
    include('../include/functions.inc.php');
	include('../include/template.class.php');
	include('../include/book.class.php');
	
	
	// PROJECT
	$PROJECT = setProject();
	
	
	// Ndyshoret primare
	define('TPL','../include/styles/'.$PROJECT['style'].'/library/author.html');
	define('FILENAME',basename($_SERVER["PHP_SELF"]));
	define('UID',$_SESSION['user_id']);
	define('ID',$_GET['id']);
	
	
	// DB CONNECT
	dbOpen("library");	
	
	
	// TMP CLASS
	$tmp = new Template(TPL,$PROJECT['lang']);
	
	
	// BOOK CLASS
	$book = new Book(ID);
	$book->setBook();
		
	// MENUES
	$getBook = "?id=".ID;
	$tmp->setContent("CATEGORY",$tmp->menu("category","../library"));
	$tmp->setContent("BOOKMENU",$tmp->menu("book",FILENAME,$getBook));
	$tmp->setContent("SECTIONS", sections($book->BOOK['sid']));
	$tmp->setContent("FOOTMENU",$tmp->menu("foot"));
	

	// ACCORDIONS
	$tmp->setContent("INFOBOOK",$book->BOOK);
	$tmp->setContent("FROMAUTHOR",$book->fromAuthor());
	$tmp->setContent("READMORE",$book->readMore());
	$tmp->setContent("NEWS",news("library"));
	$tmp->setContent("RANDOM",randomContent("library"));
	
	
	// AUTHOR
	$AUTHOR = mysql_fetch_assoc(mysql_query("SELECT id,image,description FROM authors WHERE id = '".$book->BOOK['author_id']."' "));
	$AUTHOR['author'] = $book->BOOK['author'];
	
	
	// Nese nuk ekziston pershkrimi i autorit
	if (empty($AUTHOR['description'])) {
		
		// Trego porosin ne vend te formes
		$MESSAGE = $tmp->xmlContent('nouserdescription');
		$AUTHOR = array();
	}
	else 
		// Xhvendos bllokun e porosis
		$MESSAGE = array();
		
		
	
	// Nese nuk ekziston fotografi per autorin
	if (empty($AUTHOR['image']))
		// Largo bllokun e fotografise
		$tmp->setContent("IMG",array());
	
	
	// MESSAGE
	$tmp->setContent("MESSAGE",$MESSAGE);
	
	
	// AUTHOR
	$tmp->setContent("AUTHOR",$AUTHOR);
	
	
	// LABELS
	$tmp->setLabels();
	
	
	// DISPLAY ALL						  
	echo $tmp->vorlage;
?>